/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package interfaces;

import dao.DetetiveDAO;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;
import modelo.Detetive;

/**
 *
 * @author marcieli
 */
public class FrameDetetiveGerencia extends javax.swing.JInternalFrame {

    List<Detetive> lista = new ArrayList<Detetive>();
    Integer contCodigo = 0;
    Integer posicaolista;

    public FrameDetetiveGerencia() {
        initComponents();
        lista = det.Listar();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jPanel7 = new javax.swing.JPanel();
        ButPrimeiro2 = new javax.swing.JButton();
        ButAnterior2 = new javax.swing.JButton();
        ButProximo2 = new javax.swing.JButton();
        ButUltimo2 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        txtCod = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        txtNome = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        txtEmail = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        txtNumC = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        ComboEquipe = new javax.swing.JComboBox();
        jPanel4 = new javax.swing.JPanel();
        ButInserir = new javax.swing.JButton();
        ButAtualizar = new javax.swing.JButton();
        ButNovo = new javax.swing.JButton();
        ButRemover = new javax.swing.JButton();

        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setTitle("Gerenciar detetive");

        jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jLabel8.setText("Carregar Imagem");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(93, Short.MAX_VALUE)
                .addComponent(jLabel8)
                .addGap(100, 100, 100))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(85, 85, 85)
                .addComponent(jLabel8)
                .addContainerGap(79, Short.MAX_VALUE))
        );

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("Navegação"));

        ButPrimeiro2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        ButPrimeiro2.setText("Primeiro");
        ButPrimeiro2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButPrimeiro2ActionPerformed(evt);
            }
        });

        ButAnterior2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        ButAnterior2.setText("Anterior");
        ButAnterior2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButAnterior2ActionPerformed(evt);
            }
        });

        ButProximo2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        ButProximo2.setText("Proximo");
        ButProximo2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButProximo2ActionPerformed(evt);
            }
        });

        ButUltimo2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        ButUltimo2.setText("Ultimo");
        ButUltimo2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButUltimo2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(ButPrimeiro2, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ButAnterior2, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ButProximo2, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ButUltimo2, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(ButPrimeiro2)
                .addGap(18, 18, 18)
                .addComponent(ButAnterior2)
                .addGap(18, 18, 18)
                .addComponent(ButProximo2)
                .addGap(18, 18, 18)
                .addComponent(ButUltimo2))
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Dados", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14), java.awt.Color.darkGray)); // NOI18N

        txtCod.setEditable(false);

        jLabel9.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel9.setText("Código:");

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel2.setText("Nome:");

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel5.setText("email:");

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel6.setText("Número de casos:");

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel7.setText("Equipe:");

        ComboEquipe.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "BOPE", "OS VINGADORES", "LIGA DA JUSTIÇA", "OS INCRIVEIS", "POWER RANGERS", "SMURFS" }));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtNome, javax.swing.GroupLayout.PREFERRED_SIZE, 319, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addGap(18, 18, 18)
                        .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 297, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtNumC, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addGap(18, 18, 18)
                        .addComponent(ComboEquipe, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGap(7, 7, 7)
                    .addComponent(jLabel9)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(txtCod, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(275, Short.MAX_VALUE)))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(49, 49, 49)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(txtNumC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(ComboEquipe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jLabel9)
                        .addComponent(txtCod, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(163, Short.MAX_VALUE)))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Opções"));

        ButInserir.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        ButInserir.setText("Inserir");
        ButInserir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButInserirActionPerformed(evt);
            }
        });

        ButAtualizar.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        ButAtualizar.setText("Atualizar");
        ButAtualizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButAtualizarActionPerformed(evt);
            }
        });

        ButNovo.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        ButNovo.setText("Novo");
        ButNovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButNovoActionPerformed(evt);
            }
        });

        ButRemover.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        ButRemover.setText("Excluir");
        ButRemover.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButRemoverActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(ButInserir, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(ButAtualizar, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(14, 14, 14)
                .addComponent(ButNovo, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(ButRemover, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ButInserir)
                    .addComponent(ButAtualizar)
                    .addComponent(ButNovo)
                    .addComponent(ButRemover))
                .addGap(0, 15, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(44, 44, 44)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 40, Short.MAX_VALUE)
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(29, 29, 29))
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void ButPrimeiro2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButPrimeiro2ActionPerformed

        Detetive d = lista.get(0);

        txtCod.setText(d.getCodigo().toString());
        txtNome.setText(d.getNomeDet());
        txtEmail.setText(d.getEmail());
        txtNumC.setText(d.getNumeroCasos().toString());
        ComboEquipe.setSelectedItem(d.getEquipe());

        posicaolista = 0;
    }//GEN-LAST:event_ButPrimeiro2ActionPerformed

    private void ButAnterior2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButAnterior2ActionPerformed
        if (posicaolista > 0) {
            posicaolista = posicaolista - 1;
            Detetive d = lista.get(posicaolista);

            txtCod.setText(d.getCodigo().toString());
            txtNome.setText(d.getNomeDet());

            txtEmail.setText(d.getEmail());
            txtNumC.setText(d.getNumeroCasos().toString());
            ComboEquipe.setSelectedItem(d.getEquipe());

            posicaolista = lista.size() - 1;
        }
    }//GEN-LAST:event_ButAnterior2ActionPerformed

    private void ButProximo2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButProximo2ActionPerformed

        if (posicaolista < (lista.size() - 1)) {
            posicaolista = posicaolista + 1;
            Detetive d = lista.get(posicaolista);
            txtCod.setText(d.getCodigo().toString());
            txtNome.setText(d.getNomeDet());

            txtEmail.setText(d.getEmail());
            txtNumC.setText(d.getNumeroCasos().toString());
            ComboEquipe.setSelectedItem(d.getEquipe());
            posicaolista = lista.size() - 1;
        }
    }//GEN-LAST:event_ButProximo2ActionPerformed

    private void ButUltimo2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButUltimo2ActionPerformed
        Detetive d = lista.get((lista.size() - 1));
        txtCod.setText(d.getCodigo().toString());

        txtNome.setText(d.getNomeDet());
        txtEmail.setText(d.getEmail());
        txtNumC.setText(d.getNumeroCasos().toString());
        ComboEquipe.setSelectedItem(d.getEquipe());

        posicaolista = lista.size() - 1;
    }//GEN-LAST:event_ButUltimo2ActionPerformed

    private void ButInserirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButInserirActionPerformed
        if (txtNome.getText().equals("") || txtEmail.getText().equals("")
                || txtNumC.getText().equals("") || ComboEquipe.getSelectedItem().equals("")) {
            JOptionPane.showMessageDialog(null, "Todos os campos são obrigatórios");

        } else {

            det.Cadastrar(CarregaDados());
            JOptionPane.showMessageDialog(null, "Detetive inserido com sucesso");
            LimparDados();
            lista = det.Listar();
        }
    }//GEN-LAST:event_ButInserirActionPerformed

    private void ButAtualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButAtualizarActionPerformed
//        if (txtNome.getText().equals("") || txtEmail.getText().equals("")
//                || txtNumC.getText().equals("") || ComboEquipe.getSelectedItem().equals("")) {
//            JOptionPane.showMessageDialog(null, "Todos os campos são obrigatórios");
//        } else {
//
//            Integer codigo = Integer.parseInt(txtCod.getText());
//            for (Detetive d : lista) {
//                if (codigo == d.getCodigo()) {
//                    d.setNomeDet(txtNome.getText());
//                    d.setEmail(txtEmail.getText());
//                    d.setNumeroCasos(Integer.parseInt(txtNumC.getText()));
//                    d.setEquipe(ComboEquipe.getSelectedItem().toString());
//                    break;
//                }
//            }
//            JOptionPane.showMessageDialog(null, "Detetive atualizada com sucesso");
//            LimparDados();
//
//        }
    }//GEN-LAST:event_ButAtualizarActionPerformed

    private void ButNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButNovoActionPerformed
        LimparDados();
    }//GEN-LAST:event_ButNovoActionPerformed

    private void ButRemoverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButRemoverActionPerformed
        int confirma = JOptionPane.showConfirmDialog(null, "Deseja excluir?");
        if (confirma == 0) {
            d.setCodigo(Integer.parseInt(txtCod.getText()));
            det.Excluir(d);
            LimparDados();
            lista = det.Listar();

        }

    }//GEN-LAST:event_ButRemoverActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton ButAnterior2;
    private javax.swing.JButton ButAtualizar;
    private javax.swing.JButton ButInserir;
    private javax.swing.JButton ButNovo;
    private javax.swing.JButton ButPrimeiro2;
    private javax.swing.JButton ButProximo2;
    private javax.swing.JButton ButRemover;
    private javax.swing.JButton ButUltimo2;
    private javax.swing.JComboBox ComboEquipe;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JTextField txtCod;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtNome;
    private javax.swing.JTextField txtNumC;
    // End of variables declaration//GEN-END:variables
DetetiveDAO det = new DetetiveDAO();
    Detetive d = new Detetive();

    public Detetive CarregaDados() {

        d.setNomeDet(txtNome.getText());
        d.setEmail(txtEmail.getText());
        d.setNumeroCasos(Integer.parseInt(txtNumC.getText()));
        d.setEquipe(ComboEquipe.getSelectedItem().toString());

        return d;
    }

    public void LimparDados() {
        txtCod.setText(null);
        txtNome.setText(null);
        txtEmail.setText(null);
        txtNumC.setText(null);
        ComboEquipe.setSelectedItem(null);
    }
}
